Write-Host "Installing dependencies for cloud functions..." -ForegroundColor Green

$cloudFunctions = @(
    "cleanupAndResetTasks",
    "manageDorms",
    "saveCheck",
    "completeTask",
    "initDatabase",
    "generateQRCode",
    "createTask",
    "fixDormData"
)

foreach ($func in $cloudFunctions) {
    $path = "cloudfunctions\$func"
    if (Test-Path $path) {
        Write-Host "Installing dependencies for $func..." -ForegroundColor Cyan
        Set-Location $path
        npm install --save wx-server-sdk@~2.6.3
        Set-Location ..\..\
    } else {
        Write-Host "Function $func not found, skipping." -ForegroundColor Yellow
    }
}

Write-Host "All dependencies installed successfully!" -ForegroundColor Green 